import { createApp } from 'vue';
import './plugins/assets';
import '/node_modules/element-plus/dist/index.css';
import './styles/iconfont/iconfont.css';
import STable, { setConfig } from '@surely-vue/table';
import { hackLicenseKey } from '@/utils/surely-vue-table-key';
import { setupAppVersionNotification, setupDayjs, setupIconifyOffline, setupLoading, setupNProgress } from './plugins';
import { setupStore } from './store';
import { setupRouter } from './router';
import { setupI18n } from './locales';
import App from './App.vue';
import installDirective from './directive';
import '@surely-vue/table/dist/index.less';
import { useAuthStore } from './store/modules/auth';

async function setupApp() {
  setupLoading();

  setupNProgress();

  setupIconifyOffline();

  setupDayjs();

  const app = createApp(App);
  app.use(STable);
  setConfig({
    animateRows: false
  });
  setupStore(app);

  // 初始化用户信息
  const authStore = useAuthStore();
  await authStore.initUserInfo();

  await setupRouter(app);
  hackLicenseKey();
  setupI18n(app);
  installDirective(app);
  setupAppVersionNotification();
  app.mount('#app');
}

setupApp();
